package com.slz3.business.module.wmsManagement.wmsPurchaseOrderLine.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderLine.domain.WmsPurchaseOrderLine;
import com.slz3.business.module.wmsManagement.wmsPurchaseOrderLine.domain.WmsPurchaseOrderLineFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class WmsPurchaseOrderLineTransactionalServiceImpl implements WmsPurchaseOrderLineTransactionalService {

    @Override
    public WmsPurchaseOrderLine modify(WmsPurchaseOrderLine wmsPurchaseOrderLineNew) {
        Repositorys.wmsPurchaseOrderLine.test();
        Repositorys.wmsPurchaseOrderLine.save(WmsPurchaseOrderLineFactory.initBaseFields());
        System.err.println(1/0);
        wmsPurchaseOrderLineNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.wmsPurchaseOrderLine.saveAndFlush(wmsPurchaseOrderLineNew);
    }

    @Override
    public List<WmsPurchaseOrderLine> batchModify(List<WmsPurchaseOrderLine> wmsPurchaseOrderLineList) {
        return Repositorys.wmsPurchaseOrderLine.saveAll(wmsPurchaseOrderLineList);
    }
}
